<template>
	<view class="content">
		<view class="ipts" v-if="info">
			<view class="info-item">
				<span>姓名：</span>
				<input type="text" disabled v-model="info.realname" placeholder="" placeholder-class="place-class">
			</view>
			<view class="info-item">
				<span>身份证号：</span>
				<text style="color: #999;font-size: 28rpx;">{{info.ID_num || '暂无'}}</text>
			</view>
			<view class="info-item" v-if="info.department">
				<span>部门：</span>
				<text style="color: #999;font-size: 28rpx;">{{info.department}}</text>
			</view>
			<view class="info-item">
				<span>电话：</span>
				<text style="color: #999;font-size: 28rpx;">{{info.mobile || '暂无'}}</text>
			</view>
			<view class="info-item">
				<span>地址：</span>
				<text style="color: #999;font-size: 28rpx;">{{info.township_id}}{{info.village_id}}</text>
			</view>
			<view class="info-item">
				<span>{{login}}考核分数：</span>
				<text
					style="color: #999;font-size: 28rpx;">{{info.level || '0'}}</text>
			</view>
			<view class="info-item">
				<span>账号：</span>
				<input type="text" disabled v-model="info.username" placeholder="请输入账号" placeholder-class="place-class">
			</view>
			<view class="info-item" style="text-align: right;" @tap="xgmm">
				修改密码
			</view>
		</view>
		<view class="btn" @click="remoSync">退出登录</view>
		<u-tabbar v-model="current" :list="list" active-color='#003690' :before-switch="beforeSwitch"></u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: '',
				token: '',
				login: '',
				list: [{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						isDot: false,
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
						isDot: false,
						customIcon: false,
					},
				],
				current: 1
			};
		},
		onLoad() {
			uni.getStorage({
				key: 'userinfo'
			}).then(res => {
				this.userinfo = res.data
			})
			this.$request.request({
				url:'/index/meke',
				header:{
					token:uni.getStorageSync('token')
				},
				method:'GET',
			}).then(res=>{
				if(res.data.code==1){
					this.getInstallDetail()
				}
			})

			// this.getInstallDetail()
		},
		onShow() {
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data
			})
			uni.getStorage({
				key: 'login'
			}).then(da => {
				this.login = da[1].data
				console.log(this.login)
			})
		},

		methods: {
			beforeSwitch(index) {
				console.log(index)
				// this.current=index;
				if (index == 0) {
					uni.redirectTo({
						url: '/pagesA/index/volunteerindex'
					})
				} else if (index == 1) {
					// uni.navigateTo({
					// 	url: '/pages/user/me'
					// })
				}

			},
			xgmm() {
				uni.navigateTo({
					url: '/pages/resetpasswd/resetpasswd'
				})
			},
			searchFocus() {
				this.showAcount = false
			},
			infoClick() {
				this.showAcount = !this.showAcount
			},
			// 退出登录
			logOut() {
				uni.clearStorage({
					key: 'logininfo',
					success: () => {
						this.showAcount = false
						uni.redirectTo({
							url: '../../login/login'
						})
					}
				})
			},
			// 跳转至记录页面
			toJiLu() {
				uni.navigateTo({
					url: './jilu'
				})
			},
			// 跳转用户信息页面
			toCaiLiao(id) {
				uni.navigateTo({
					url: '../userinfo/uninstall?id=' + id
				})
			},
			// 点击获取安装数据
			searchUser(val) {
				// this.getInstallDetail ()
				this.dosearch = true
				uni.navigateTo({
					url: '../query/query?key=' + val
				})
			},
			// 获取用户数据
			async getInstallDetail() {
				let that = this
				uni.getStorage({
					key: 'login'
				}).then(da => {
					if (da[1].data == '员工') {
						that.$request.request({
							url: '/staff/get_member_info',
							method: 'POST',
							data: {
								token: that.token
							}
						}).then(res => {
							that.info = res.data.data
						})

					} else if (da[1].data == '用户') {
						that.$request.request({
							url: '/user/get_member_info',
							method: 'POST',
							data: {
								token: that.token
							}
						}).then(res => {
							that.info = res.data.data
							console.log(this.info)
						})
					} else if (da[1].data == '安全员') {
						that.$request.request({
							url: '/safer/get_member_info',
							method: 'POST',
							data: {
								token: that.token
							}
						}).then(res => {
							that.info = res.data.data
						})
					} else if (da[1].data == '协管员') {
						that.$request.request({
							url: '/assistant/get_member_info',
							method: 'POST',
							data: {
								token: that.token
							}
						}).then(res => {
							that.info = res.data.data
						})
					}
				})


			},
			remoSync() {
				uni.showModal({
					title: '提示',
					content: '确定要退出登录吗？',
					success: function(res) {
						if (res.confirm) {
							uni.clearStorage()
							uni.reLaunch({
								url: '/pages/login/login'
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			}
		},

	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F5F5F5;
		// padding-bottom: 200rpx;
		// margin-bottom: 150rpx;
	}

	.content {
		border-top: 15rpx solid #f3f3f3;
		padding-bottom: 20rpx;
	}

	.ipts {
		background-color: #fff;
	}

	.info-item {
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 100rpx;
		width: 100%;
		padding: 0 30rpx;
		background-color: #fff;
		font-size: 28rpx;
		color: #333;
		line-height: 100rpx;

		input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #999999;
		}

		border-bottom: 15rpx solid #f3f3f3;
	}

	.info-img {
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;

		image {
			width: 64rpx;
			height: 64rpx;
		}
	}

	.hengxian {
		width: 700rpx;
		height: 2rpx;
		background-color: #dddddd;
		margin: 0 auto;
	}

	.place-class {
		font-size: 28rpx;
		color: #999;
	}

	.btn {
		width: 646rpx;
		height: 80rpx;
		margin: 74rpx auto;
		text-align: center;
		line-height: 80rpx;
		border-radius: 10rpx;
		background-image: linear-gradient(to bottom, #2979ff, #2979ff);
		font-size: 28rpx;
		color: #E5EFFE;
	}

	.btn:active {
		background: rgba(0, 0, 0, 0.4);
	}
</style>
